<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script>

        Function.prototype.aBind = Function.prototype.bind || function(){
            if(typeof this !== 'function') throw new TypeError('应使用函数进行绑定操作');
            var that = this;
            var args = arguments;
            return function(){
                return that.apply(this instanceof arguments.callee ? this : args[0],[].slice.call(args,1).concat([].slice.call(arguments)));
            };
        };
        
        function fn(a,b,c){
            this.age = '19';
            this.numb0 = a;
            this.numb1 = b;
            this.numb2 = c;
            console.log(this);
            console.log(arguments);
        }
        var obj = {name:"zs"};
        var foo = fn.aBind(obj,1,2,3);
        //执行时this 指向obj,且传参是绑定时的参数 concat 执行时的传参
        foo(4,5,6);
        //如果是new引导  会忽略this的指向
        var foo2 = new foo(7,8,9);
        console.log(foo2);
    </script>
</body>
</html>